# -*- coding: utf-8 -*-
# Author: tom
# time: 2024/2/29 18:06
# description：

import calendar
import re
import time
import allure

from playwright.sync_api import Page, expect

from repository import modelListObject, modelUploadObject, modelConvertObject, modelFolderObject, modelSelectObject, \
    modelMoreObject, modelPreviewObject
from utils.configParse import config


class ModelManagePageException(Exception):
    def __init__(self, message):
        self.message = message

    def __str__(self):
        return f'Page_Model_Page raise exception:{self.message}'


class ModelPage:
    def __init__(self, page: Page):
        self.page = page
        self.model_manage_text_loc = page.locator(modelListObject.model_manage_text)
        self.model_lists_loc = page.locator(modelListObject.model_lists)
        self.model_lists_data_loc = page.locator(modelListObject.model_lists_data)
        self.model_lists_page_number_loc = page.locator(modelListObject.model_lists_page_number)
        self.model_lists_next_page_loc = page.locator(modelListObject.model_lists_next_page)
        self.model_name_loc = page.locator(modelListObject.model_name)
        self.model_status_loc = page.locator(modelListObject.model_status)
        self.model_status_all_loc = page.locator(modelListObject.model_status_all)
        self.model_more_loc = page.locator(modelListObject.model_more)
        self.model_viewer_loc = page.locator(modelListObject.model_viewer)
        self.model_upload_loc = page.locator(modelUploadObject.model_upload_file)
        self.model_upload_box_loc = page.locator(modelUploadObject.model_upload_box)
        self.model_upload_box_loc = page.locator(modelUploadObject.model_upload_box)
        self.model_upload_file_loc = page.locator(modelUploadObject.model_upload_file)
        # 查询设置相关
        self.model_select_input_loc = page.get_by_placeholder(modelSelectObject.model_select_input)
        self.model_select_button_loc = page.get_by_role('button', name=modelSelectObject.model_select_button)
        self.model_select_reset_loc = page.locator(modelSelectObject.model_select_reset)
        self.model_select_setting_loc = page.locator(modelSelectObject.model_select_setting)
        self.model_select_setting_box_loc = page.locator(modelSelectObject.model_select_setting_box)
        self.model_select_setting_box_context_loc = page.locator(modelSelectObject.model_select_setting_box_context)
        self.model_select_setting_box_input_loc = page.locator(modelSelectObject.model_select_setting_box_input)
        self.model_select_setting_selectAll_input_loc = page.locator(
            modelSelectObject.model_select_setting_selectAll_input)
        self.model_select_setting_confirm_loc = page.locator(modelSelectObject.model_select_setting_confirm)
        self.model_select_setting_name_loc = page.locator(modelSelectObject.model_select_setting_name)
        self.query_model_name_and_id_loc = page.get_by_placeholder(modelSelectObject.query_model_name_and_id)
        self.query_model_tag_loc = page.get_by_placeholder(modelSelectObject.query_model_tag)
        self.click_model_format_and_status_loc = page.locator(modelSelectObject.click_model_format_and_status)
        self.query_model_status_and_format_select_loc = page.locator(
            modelSelectObject.query_model_status_and_format_select)
        self.query_model_status_and_format_select_box_loc = page.locator(
            modelSelectObject.query_model_status_and_format_select_box)
        self.query_model_condition_info_loc = page.locator(modelSelectObject.query_model_condition_info)

        # 新建文件夹
        self.model_create_fload_loc = page.locator(modelFolderObject.model_create_folder)
        self.model_folder_box_title_loc = page.locator(modelFolderObject.model_folder_box_title)
        self.model_folder_box_input_loc = page.get_by_placeholder(modelFolderObject.model_folder_box_input)
        self.model_folder_box_cancel_loc = page.get_by_role('button', name=modelFolderObject.model_folder_box_cancel)
        self.model_folder_box_confirm_loc = page.get_by_role('button',
                                                             name=modelFolderObject.model_folder_box_confirm)
        # 转换
        self.model_convert_loc = page.locator(modelConvertObject.model_convert)
        self.model_convert_box_name_loc = page.locator(modelConvertObject.model_convert_box_name)
        self.model_convert_confirm_loc = page.locator(modelConvertObject.model_convert_confirm)

        # 更多
        self.model_more_box_loc = page.locator(modelMoreObject.model_more_box)
        self.model_share_loc = page.locator(modelMoreObject.model_share)
        self.model_share_box_loc = page.locator(modelMoreObject.model_share_box)
        self.model_share_box_text = page.locator(modelMoreObject.model_share_box_text)
        self.model_share_box_shareContent_loc = page.locator(modelMoreObject.model_share_box_shareContent)
        self.model_share_box_ShareValidityPeriod_loc = page.locator(modelMoreObject.model_share_box_ShareValidityPeriod)
        self.model_share_box_Password_loc = page.locator(modelMoreObject.model_share_box_Password)
        self.model_share_periodOfValidity_oneDay_loc = page.locator(modelMoreObject.model_share_periodOfValidity_oneDay)
        self.model_share_periodOfValidity_sevenDay_loc = page.locator(
            modelMoreObject.model_share_periodOfValidity_sevenDay)
        self.model_share_periodOfValidity_foreverDay_loc = page.locator(
            modelMoreObject.model_share_periodOfValidity_foreverDay)
        self.model_share_set_nopassword_loc = page.locator(modelMoreObject.model_share_set_nopassword)
        self.model_share_set_havapassword_loc = page.locator(modelMoreObject.model_share_set_havapassword)
        self.model_share_set_password_loc = page.get_by_placeholder(modelMoreObject.model_share_set_password,
                                                                    exact=True)
        self.model_share_box_confirm_button_loc = page.get_by_role("button",
                                                                   name=modelMoreObject.model_share_box_confirm_button)
        self.model_share_success_box_loc = page.locator(modelMoreObject.model_share_success_box)
        self.model_share_box_close_button_loc = page.get_by_role("button",
                                                                 name=modelMoreObject.model_share_box_close_button)
        # 详情
        self.model_detail_box_loc = page.locator(modelMoreObject.model_detail_box)
        self.model_detail_box_button_loc = page.locator(modelMoreObject.model_detail_box_button)
        # 渲染信息
        self.model_render_info_box_loc = page.locator(modelMoreObject.model_render_info_box)
        self.model_render_info_box_button_loc = page.locator(modelMoreObject.model_render_info_box_button)
        # 删除
        self.model_delete_box_loc = page.locator(modelMoreObject.model_delete_box)
        self.model_delete_confirm_button_loc = page.get_by_role('button',
                                                                name=modelMoreObject.model_delete_confirm_button)
        # 批量删除
        # 模型预览
        self.model_preview_toolbar_loc = page.locator(modelPreviewObject.model_preview_toolbar)
        self.model_preview_close_button_loc = page.locator(modelPreviewObject.model_preview_close_button)
        self.model_preview_loading_loc = page.locator(modelPreviewObject.model_preview_loading)

    @allure.step('进入模型管理模块')
    def navigate(self, envir):
        # 测试环境
        try:
            if envir == "test":
                self.page.goto(
                    config.get_ini_login_url('xbasetest_url') + '/console/model-management/appInfo-manage')
                self.model_manage_text_loc.wait_for(state="visible")
            # stage环境
            elif envir == "stage":
                self.page.goto(config.get_ini_login_url('xbasestage_url') + '/console/model-management/appInfo-manage')
        except Exception as e:
            print('navigate方法存在问题，路径可能更新了')

    @allure.step('勾选查询设置中的内容')
    def model_query_setting_box(self):
        self.model_select_setting_loc.click()
        expect(self.model_select_setting_box_loc).to_be_visible()
        self.model_select_setting_selectAll_input_loc.click()
        self.model_select_setting_selectAll_input_loc.click()

    @allure.step('利用查询设置中的内容进行搜索设置')
    def model_query_setting_func(self, model_select_setting_name):
        """
        针对模型管理查询设置重构成统一的方法
        功能：传入查询设置中的内容，来自动匹配对应的内容
        :return:
        """
        try:
            self.model_query_setting_box()
            model_select_setting_contexts = self.model_select_setting_box_context_loc.count()
            for x in range(1, model_select_setting_contexts + 1):
                if isinstance(model_select_setting_name, list):
                    for y in model_select_setting_name:
                        if y == self.page.locator(
                                "//div[@class='mms-checkbox-group']/div[{}]//span[2]".format(x)).inner_text():
                            self.page.locator(
                                "//div[@class='mms-checkbox-group']/div[{}]//input".format(x)).click()
                            break
                else:
                    if model_select_setting_name == self.page.locator(
                            "//div[@class='mms-checkbox-group']/div[{}]//span[2]".format(x)).inner_text():
                        self.page.locator(
                            "//div[@class='mms-checkbox-group']/div[{}]//input".format(x)).click()
                        break
            self.model_select_setting_confirm_loc.click()
        except Exception as e:
            print(f"model_query_setting_func方法出现异常：{e}")

    @allure.step('输入查询内容，执行模型查询')
    def search_input(self, model_name_or_id):
        """
        模型搜索框搜索,主要针对模型名称和id的内容输入,不适合多个查询条件
        :return:
        """
        try:
            self.query_model_name_and_id_loc.fill(model_name_or_id)
            self.click_model_query_button()
            # 查看列表的数量
            model_list_numbers = self.model_lists_loc.count()
            assert model_list_numbers >= 0
        except Exception as e:
            print(f'search_input方法异常，请查看：{e}')

    @allure.step('执行模型状态或格式或标签查询')
    def search_model_status_format_tag(self, query_model_status_format_tag):
        """
        针对模型查询中的模型状态、格式以及标签进行统一方法调用
        :param query_model_status_format_tag:
        :return:
        """
        try:
            self.click_model_format_and_status_loc.click()
            self.query_model_status_and_format_select_box_loc.wait_for(state='visible')
            model_status_format_counts = self.query_model_status_and_format_select_loc.count()
            for x in range(1, model_status_format_counts + 1):
                model_status_format_tag_info = self.page.locator(
                    "//div[@class='rc-virtual-list-holder-inner']/div[{}]/div[@class='mms-select-item-option-content']".format(
                        x)).inner_text()
                if model_status_format_tag_info == query_model_status_format_tag:
                    self.page.locator(
                        "//div[@class='rc-virtual-list-holder-inner']/div[{}]/div[@class='mms-select-item-option-content']".format(
                            x)).click()
                    self.model_select_button_loc.click()
                    break
        except Exception as e:
            print(f'search_model_status方法出现异常，请查看：{e}')

    @allure.step('点击模型查询按钮，开始查询')
    def click_model_query_button(self):
        self.model_select_button_loc.click()

    def assembly_button(self):
        """
        装配模型按钮
        :return:
        """
        pass

    @allure.step("新建模型文件夹")
    def new_folder_button(self, folder_name):
        """
        新建文件夹操作
        :return:
        """
        try:
            self.model_create_fload_loc.click()
            expect(self.model_folder_box_title_loc).to_have_text("新建文件夹")
            self.model_folder_box_input_loc.fill(folder_name)
            self.model_folder_box_confirm_loc.click()
            self.model_folder_box_title_loc.wait_for(state='hidden')
            # 查看列表的数量
            model_list_numbers = self.model_lists_loc.count()
            assert model_list_numbers >= 0
        except Exception as e:
            print(f"new_folder_button方法出现异常，请查看：{e}")
        finally:
            return folder_name

    @allure.step("上传模型文件")
    def upload_model_file(self, model_file):
        """
        上传模型文件
        :return:
        """
        try:
            model_list_data_info = self.model_lists_data_loc.count()
            print("model_list_data_info--》", model_list_data_info)
            if model_list_data_info:
                self.model_upload_file_loc.set_input_files(model_file)
                # self.page.set_input_files(modelUploadObject.model_upload_file, model_file)
                expect(self.model_upload_box_loc).to_be_visible(visible=True, timeout=10000)
                self.model_upload_box_loc.wait_for(state='hidden')
                upload_after_model_file_name = self.model_name_loc.inner_text()
                if model_list_data_info != upload_after_model_file_name:
                    print('===>', model_list_data_info, upload_after_model_file_name)
                    expect(self.model_name_loc).to_have_text(upload_after_model_file_name, timeout=5000)
                    return upload_after_model_file_name
            else:
                upload_before_model_file_name = self.model_name_loc.inner_text()
                # 判断模型列表第一个是否是文件夹
                if re.match(r'^文件夹', upload_before_model_file_name):
                    self.model_name_loc.click()
                self.model_upload_file_loc.set_input_files(model_file)
                expect(self.model_upload_box_loc).to_be_visible(visible=True, timeout=10000)
                self.model_upload_box_loc.wait_for(state='hidden')
                upload_after_model_file_name = self.model_name_loc.inner_text()
                if upload_before_model_file_name != upload_after_model_file_name:
                    print('===>', upload_before_model_file_name, upload_after_model_file_name)
                    expect(self.model_name_loc).to_have_text(upload_after_model_file_name, timeout=5000)
                    return upload_after_model_file_name
        except Exception as e:
            print(f"upload_model_file方法异常，请查看：{e}")

    def delete_button(self):
        """
        页面右上角的删除按钮
        :return:
        """
        pass

    @allure.step("模型转换")
    def convert_button(self, model_file, is_convert, is_batch_convert, model_level=None):
        """
        转换和重新转换按钮
        :return:
        """
        if is_convert:
            model_lists_count = self.model_lists_loc.count()
            convert_file = self.upload_model_file(model_file)
            print("====>", convert_file, self.model_status_loc.inner_text(), model_lists_count)
            for x in range(1, model_lists_count + 1):
                model_format = self.page.locator(modelListObject.model_format_list.format(x)).inner_text()
                if convert_file and self.model_status_loc.inner_text() == '上传成功' and model_format != "rvt":
                    print("走1")
                    self.model_convert_loc.click()
                else:
                    print("走2")
                    self.model_convert_loc.click()
                    expect(self.model_convert_box_name_loc).to_have_text('格式转换')
                    model_accuracy_level_result = self.page.query_selector_all(modelConvertObject.model_accuracy_level)
                    print("model_accuracy_level_result===》", model_accuracy_level_result)
                    if "构件级" not in model_level:
                        print("这里应该不走啊")
                        # 如果用例中没有要求构件集，需要取消构件级勾选
                        self.page.locator(modelConvertObject.model_accuracy_level_input.format(3)).click()
                    for index, model_accuracy_level in enumerate(model_accuracy_level_result):
                        print("循环：", index, model_accuracy_level.inner_text())
                        if model_accuracy_level.inner_text() in model_level:
                            is_checked = self.page.is_checked(
                                modelConvertObject.model_accuracy_level_input.format(index + 1))
                            print("is_checked--->", is_checked)
                            if is_checked is not True:
                                print("is checked 为 false:{}".format(index))
                                self.page.locator(
                                    modelConvertObject.model_accuracy_level_input.format(index + 1)).click()
                print("执行了吗")
                expect(self.model_convert_box_name_loc).to_have_text('格式转换')
                self.model_convert_confirm_loc.click()
                print("开始转换")
                self.model_convert_box_name_loc.wait_for(state='hidden')
                while True:
                    if self.model_status_loc.inner_text() in ['转换成功', '转换失败']:
                        break
                break
        if is_batch_convert:
            self.model_upload_file_loc.set_input_files(model_file)
            expect(self.model_upload_box_loc).to_be_visible(visible=True, timeout=10000)
            self.model_upload_box_loc.wait_for(state='hidden')
            for x in range(1, self.model_lists_page_number_loc.count() + 1):
                print("第{}页".format(x))
                active_out = True
                while active_out:
                    model_list_numbers = self.model_lists_loc.count()
                    if "上传成功" in self.model_status_all_loc.all_text_contents():
                        print("开始判断是不是上传成功")
                        for y in range(1, model_list_numbers + 1):
                            self.page.locator(
                                "//tbody[@class='mms-table-tbody']/tr[{}]/td[8]//button[contains(@class,'transfer-btn')]".format(
                                    y)).click()
                            element_handle = self.page.query_selector(modelConvertObject.model_convert_box_name)
                            if element_handle is not None:
                                expect(self.model_convert_box_name_loc).to_have_text('格式转换')
                                self.model_convert_confirm_loc.click()
                                self.model_convert_box_name_loc.wait_for(state='hidden')
                    else:
                        print("2开始判断是不是转换成功")
                        active_in = True
                        while active_in:
                            not_in_model_status_list = [item not in self.model_status_all_loc.all_text_contents() for
                                                        item in ["上传成功", "排队中", "转换中"]]
                            all_not_in = all(not_in_model_status_list)
                            if all_not_in:
                                print("都转换成功了")
                                active_in = False
                                if self.model_lists_page_number_loc.count() - x != 0:
                                    self.model_lists_next_page_loc.click()
                                    print("下一页")
                                active_out = False

    @allure.step("预览不同格式的模型")
    def preview_button(self):
        """
        预览按钮
        :return:
        """
        try:
            model_lists = self.model_lists_loc.count()
            model_lists_page_number = self.model_lists_page_number_loc.count()
            for x in range(1, model_lists_page_number + 1):
                if self.page.locator(modelListObject.model_name_list.format(x)).inner_text().startswith('全格式'):
                    self.page.locator(modelListObject.model_name_list.format(x)).click()
                    for y in range(1, model_lists + 1):
                        model_status_info = self.page.locator(modelListObject.model_status_list.format(y)).inner_text()
                        if re.match("转换成功", model_status_info):
                            self.page.locator(modelListObject.model_viewer_list.format(y)).click()
                            self.model_preview_loading_loc.wait_for(state='visible')
                            self.model_preview_loading_loc.wait_for(state='hidden')
                            element_handle = self.page.query_selector(modelPreviewObject.model_preview_loading)
                            if element_handle:
                                self.model_preview_close_button_loc.click()
                            else:
                                print("可能出现toolbar没加载出来，预览异常")
        except Exception as e:
            print("preview_button出现异常，请查看:{}".format(e))

    @allure.step("点击模型列表中的更多")
    def more_button(self):
        """
        更多按钮
        :return:
        """
        self.model_more_loc.hover()
        self.model_more_box_loc.wait_for(state='visible')

    def more_rename_button(self):
        """
        更多中的重命名按钮
        :return:
        """
        pass

    def model_delete_public_func(self):
        """
        对于文件夹和文件的删除，提取到公共方法
        :return:
        """
        self.model_more_loc.hover()
        expect(self.model_more_box_loc).to_be_visible()
        self.page.get_by_text("删除", exact=True).click()
        expect(self.model_delete_box_loc).to_be_visible()
        self.model_delete_confirm_button_loc.click()

    @allure.step('操作模型列表更多中的删除')
    def more_delete_button(self, is_folder):
        """
        更多中的删除按钮，涉及文件和文件夹的删除
        :return:
        """
        try:
            model_list_name = self.model_name_loc.inner_text()
            if re.match(r'^文件夹', model_list_name) and is_folder:
                self.model_delete_public_func()
            else:
                self.model_delete_public_func()
        except Exception as e:
            print(f"more_delete_button出现异常，请查看：{e}")

    @allure.step("遍历模型列表操作")
    def interator_list_public_func(self, func_name=None, **kwargs):
        # try:
        model_lists = self.model_lists_loc.count()
        model_lists_page_number = self.model_lists_page_number_loc.count()
        for x in range(1, model_lists_page_number + 1):
            if self.page.locator(modelListObject.model_name_list.format(x)).inner_text().startswith('全格式'):
                self.page.locator(modelListObject.model_name_list.format(x)).click()
                for y in range(1, model_lists + 1):
                    model_status_info = self.page.locator(modelListObject.model_status_list.format(y)).inner_text()
                    if re.match("转换成功", model_status_info):
                        self.page.locator(modelListObject.model_more_list.format(y)).hover()
                        self.page.locator(modelMoreObject.model_more_box_new.format(y)).wait_for(
                            state='visible')
                        if func_name == "分享":
                            self.more_share_button(model_list_index=y,
                                                   share_validity_period=kwargs.get('share_validity_period'),
                                                   share_pwd=kwargs.get('share_pwd'))
                        elif func_name == "渲染信息":
                            self.more_rendering_info_button(model_list_index=y)
                        elif func_name == "转换详情":
                            self.more_detail_button(model_list_index=y)
        # except Exception as e:
        #     print("interator_list_public_func出现异常，请查看:{}".format(e))

    @allure.step("查看模型详情")
    def more_detail_button(self, model_list_index=None):
        """
        更多中的详情按钮
        :return:
        """
        self.page.locator(modelMoreObject.model_detail_new.format(model_list_index)).hover()
        self.page.locator(modelMoreObject.model_detail_new.format(model_list_index)).click()
        self.page.locator(modelMoreObject.model_more_box_new.format(model_list_index)).wait_for(state='hidden')
        self.model_detail_box_loc.wait_for(state='visible')
        expect(self.page.locator(modelMoreObject.model_detail_box_title)).to_have_text("转换详情")
        self.model_detail_box_button_loc.click()
        self.model_detail_box_loc.wait_for(state='hidden')

    @allure.step("分享模型管理中的模型")
    def more_share_button(self, model_list_index=None, share_validity_period=None, share_pwd=None):
        """
        更多中的分享按钮操作
        :return:
        """
        self.page.locator(modelMoreObject.model_share_new.format(model_list_index)).hover()
        self.page.locator(modelMoreObject.model_share_new.format(model_list_index)).click()
        self.page.locator(modelMoreObject.model_more_box_new.format(model_list_index)).wait_for(state='hidden')
        self.model_share_box_loc.wait_for(state='visible')
        expect(self.page.locator(modelMoreObject.model_share_box_title)).to_have_text("分享")
        self.share_box_info(share_validity_period=share_validity_period, share_pwd=share_pwd)

    @allure.step("设置分享时效_分享密码_精细等级")
    def share_box_info(self, share_validity_period=None, share_pwd=None):
        """
        设置分享时效_分享密码_精细等级
        :param share_validity_period:
        :param share_pwd:
        :return:
        """
        if share_validity_period == '1':
            self.model_share_periodOfValidity_oneDay_loc.click()
        elif share_validity_period == '7':
            self.model_share_periodOfValidity_sevenDay_loc.click()
        else:
            self.model_share_periodOfValidity_foreverDay_loc.click()
        if share_pwd:
            self.model_share_set_havapassword_loc.click()
            self.model_share_set_password_loc.fill("1234")
        self.model_share_box_confirm_button_loc.click()
        self.model_share_success_box_loc.wait_for(state='visible')
        self.model_share_box_close_button_loc.click()

    @allure.step("查看模型的渲染信息")
    def more_rendering_info_button(self, model_list_index=None):
        """
        更多中的渲染信息按钮
        :return:
        """
        self.page.locator(modelMoreObject.model_render_info_new.format(model_list_index)).hover()
        self.page.locator(modelMoreObject.model_render_info_new.format(model_list_index)).click()
        self.page.locator(modelMoreObject.model_more_box_new.format(model_list_index)).wait_for(state='hidden')
        self.model_render_info_box_loc.wait_for(state='visible')
        expect(self.page.locator(modelMoreObject.model_render_info_box_title)).to_have_text("渲染信息")
        self.model_render_info_box_button_loc.click()
        self.model_render_info_box_loc.wait_for(state='hidden')

    def more_edit_button(self):
        """
        更多中的装配编辑按钮
        :return:
        """
        pass

    @allure.step("进入模型文件夹内进行相关操作")
    def query_model_list_info(self, is_goto_model_folder, folder_name=None):
        """
        遍历模型列表，如果是文件夹需要判断是否可以进入文件夹
        :return:
        """
        model_lists_info = self.model_lists_loc.count()
        for x in range(1, model_lists_info + 1):
            model_status = self.page.locator("//tbody[@class='mms-table-tbody']/tr[{}]/td[5]".format(x)).inner_text()
            model_name = self.page.locator(
                "//tbody[@class='mms-table-tbody']/tr[{}]/td[2]//span".format(x)).inner_text()
            if model_status not in ['上传成功', '转换成功', '转换失败'] and re.match(r'^{}'.format(folder_name),
                                                                                     model_name):
                print("发现文件夹")
                if is_goto_model_folder:
                    self.page.locator("//tbody[@class='mms-table-tbody']/tr[{}]/td[2]//span".format(x)).click()
                break

    @allure.step("在文件夹内上传并转换模型-公共方法")
    def model_folder_convert_file_func(self, file_path=None):
        """
        公共方法：在文件夹内上传并转换模型
        :return:
        """
        timestamp = calendar.timegm(time.gmtime())
        self.navigate("test")
        self.new_folder_button("文件夹" + str(timestamp))
        self.query_model_list_info(True)
        self.convert_button(file_path, True, False)

    @allure.step("针对模型查询条件进行组合查询")
    def model_combinatorial_query(self, model_name=None, model_id=None, model_format=None, model_tag=None):
        """
        :param model_name_or_id: 模型查询搜索中的模型名称和模型id
        :param model_format: 模型格式
        :return:
        """
        try:
            model_query_condition = ["名称", "模型ID", "标签", "格式", "状态"]
            query_conditions = self.query_model_condition_info_loc.count()
            for x in range(1, query_conditions + 1):
                query_condition_name = self.page.locator(
                    "//div[@class='mms-row']/div[{}]/div[@class='search-item']/span".format(x)).inner_text()
                if query_condition_name in model_query_condition and query_condition_name == "名称":
                    self.page.locator(
                        "//div[@class='mms-row']/div[{}]/div[@class='search-item']//input".format(x)).fill(model_name)
                elif query_condition_name in model_query_condition and query_condition_name == "模型ID":
                    self.page.locator(
                        "//div[@class='mms-row']/div[{}]/div[@class='search-item']//input".format(x)).fill(model_id)
                elif query_condition_name in model_query_condition and query_condition_name == "格式":
                    self.search_model_status_format_tag(model_format)
                elif query_condition_name in model_query_condition and query_condition_name == "标签":
                    self.search_model_status_format_tag(model_tag)
            self.click_model_query_button()
        except Exception as e:
            print(f"model_combinatorial_query出现异常，请查看：{e}")
